package app.web.cartoon.analyse.word;

import cn.lily.com.exception.YaconException;
import cn.lily.com.lang.DeCode;
import cn.lily.web.page.BusinessPage;
import cn.lily.web.widget.sql.TSqlGrid;
import cn.lily.web.widget.standard.TButtonPilot;
/**
 * 动漫信息
 * @author JiaJ
 * @date 2017年12月7日
 *
 */
public class CartoonDetail extends BusinessPage { 

	 public void page_onLoad() throws YaconException {

		 String canName = this.getAttr("fieldValue").trim();
		 canName = DeCode.decode(canName);
		 
		 TSqlGrid cartoonDetailGrid = sqlGrid("cartoonDetailGrid");
		 cartoonDetailGrid.setDictTable("LEO_CAN_DETAIL_INFO");
		 String sqlString = "select lc.RES_ID,lc.CAN_DETAIL_ID,lc.CAN_ID,lc.CAN_DETAIL_NAME,"
							 	 + "lc.CAN_QUA,lc.CAN_KIND,lc.CAN_STAT,lc.CAN_TOTAL,"
							 	 + "to_char(lc.CAN_TIME,'yyyy-mm-dd hh24:mi:ss') CAN_TIME,"
							 	 + "lc.CAN_DEMO,lc.CAN_FIRM_MEMO,lc.CAN_TYP_MEMO "
		 		          + "from ${schema}.LEO_CAN_DETAIL_INFO lc "
		 		          + "inner join ${schema}.LEO_RES_INFO lt on lt.RES_ID=lc.RES_ID "
		 		          + "where lc.CAN_ID in "
		 		          + "(select CAN_ID from ${schema}.LEO_CAN_INFO where CAN_NAME like '%"+canName+"%')";
		 cartoonDetailGrid.setCommSqlStr(sqlString);
		 cartoonDetailGrid.setEdit(true);
		 cartoonDetailGrid.setExcuteMethod("save");
		 cartoonDetailGrid.setRefreshMethod("refresh");

		 cartoonDetailGrid.createFieldTitle("RES_ID").setFieldVisible(false);
		 cartoonDetailGrid.createFieldTitle("CAN_DETAIL_ID").setFieldVisible(false);
		 cartoonDetailGrid.createFieldTitle("CAN_ID").setFieldVisible(false);
		 cartoonDetailGrid.createFieldTitle("CAN_DETAIL_NAME");
		 cartoonDetailGrid.createFieldTitle("CAN_TYP_MEMO");
		 cartoonDetailGrid.createFieldTitle("CAN_QUA");
		 cartoonDetailGrid.createFieldTitle("CAN_KIND");
		 cartoonDetailGrid.createFieldTitle("CAN_STAT");
		 cartoonDetailGrid.createFieldTitle("CAN_TOTAL");
		 cartoonDetailGrid.createFieldTitle("CAN_TIME");
		 cartoonDetailGrid.createFieldTitle("CAN_DEMO").setFieldVisible(false);
		 cartoonDetailGrid.createFieldTitle("CAN_FIRM_MEMO").setFieldVisible(false);
		 

		 cartoonDetailGrid.detailPage().setPagePath("cartoonDetailEdit.jsp");

		 TButtonPilot cartoonDetailPilot = ButtonPilot("cartoonDetailPilot");
		 //cartoonDetailPilot.setPilotIco("/widget/buttonPilot.gif");
		 cartoonDetailPilot.setPilotText("【"+canName+"】明细信息");

		 cartoonDetailGrid.setButtonPilot(cartoonDetailPilot);
		 getPage().addElement(cartoonDetailGrid);

	 }

	 public void refresh() throws YaconException {

		 String canName = this.getViewTable().getAttributeValue("fieldValue");
		 canName = DeCode.decode(canName);
		 
		 TSqlGrid cartoonDetailGrid = sqlGrid("cartoonDetailGrid");
		 cartoonDetailGrid.setDictTable("LEO_CAN_DETAIL_INFO");
		 
		 String sqlString = "select lc.RES_ID,lc.CAN_DETAIL_ID,lc.CAN_ID,lc.CAN_DETAIL_NAME,"
							 	 + "lc.CAN_QUA,lc.CAN_KIND,lc.CAN_STAT,lc.CAN_TOTAL,"
							 	 + "to_char(lc.CAN_TIME,'yyyy-mm-dd hh24:mi:ss') CAN_TIME,"
							 	 + "lc.CAN_DEMO,lc.CAN_FIRM_MEMO,lc.CAN_TYP_MEMO "
		 		          + "from ${schema}.LEO_CAN_DETAIL_INFO lc "
		 		          + "inner join ${schema}.LEO_RES_INFO lt on lt.RES_ID=lc.RES_ID "
		 		          + "where lc.CAN_ID in "
		 		          + "(select CAN_ID from ${schema}.LEO_CAN_INFO where CAN_NAME like '%"+canName+"%')";
		 
		 cartoonDetailGrid.setCommSqlStr(sqlString);
		 this.setSelfMessage(cartoonDetailGrid.getDataElement());

	 }

	 public void save() throws YaconException {

		 this.setSuccess("数据操作成功！");

	 }

}
